import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import {
		getSetting
	} from 'config/api.js';
const store = new Vuex.Store({
	state: {
		hasLogin: false,
		userInfo: [],
		Setting:[],
	},
	mutations: {
		userLogin(state, provider) {
			state.hasLogin = true;
			state.userInfo = provider;
			uni.setStorage({
				key: "userInfo",
				data: provider
			})
		},
		getSetting(state,provider){
			state.Setting = provider;
		},
		doSetting(state) {
			getSetting().then(res=>{
				state.Setting = res.data;
				uni.setStorage({
					key: "Setting",
					data: res.data
				})
			})
			
		},
		logout(state) {
			state.hasLogin = false;
			state.userInfo = [];
			uni.removeStorage({
				key: 'userInfo'
			})
		}
	}
})

export default store
